<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //构造函数
        function Person(name,age){
            this.name = name;
            this.age = age;
            this.jump = function(){
                console.log(222);
            }
        }
        //实例对象
        let p1 = new Person("hong",18);
        p1.age = 20;
        console.log(p1);
        //往原型对象上添加属性和方法
        Person.prototype.sex = "男";
        Person.prototype.hobby = function(){
            console.log(666);
        }
        //往自身上添加属性和方法
        Person.test = function(){
            console.log("自身上添加");
        }
    </script>
</body>
</html>